home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / initsprite / RCS / initsprite.c,v < prev    next >
Encoding:
Text File  |  1992-06-16  |  20.4 KB  |  928 lines

  1. head     1.10;
  2. branch   ;
  3. access   ;
  4. symbols  sprited:1.9.1;
  5. locks    ; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.10
  10. date     92.06.16.12.45.21;  author jhh;  state Exp;
  11. branches ;
  12. next     1.9;
  13.  
  14. 1.9
  15. date     91.05.07.18.38.38;  author jhh;  state Exp;
  16. branches 1.9.1.1;
  17. next     1.8;
  18.  
  19. 1.8
  20. date     91.03.05.11.24.28;  author jhh;  state Exp;
  21. branches ;
  22. next     1.7;
  23.  
  24. 1.7
  25. date     90.01.12.13.31.09;  author jhh;  state Exp;
  26. branches ;
  27. next     1.6;
  28.  
  29. 1.6
  30. date     89.07.18.13.46.12;  author jhh;  state Exp;
  31. branches ;
  32. next     1.5;
  33.  
  34. 1.5
  35. date     89.07.12.11.47.26;  author jhh;  state Exp;
  36. branches ;
  37. next     1.4;
  38.  
  39. 1.4
  40. date     89.06.19.14.33.58;  author jhh;  state Exp;
  41. branches ;
  42. next     1.3;
  43.  
  44. 1.3
  45. date     89.01.11.12.21.21;  author mendel;  state Exp;
  46. branches ;
  47. next     1.2;
  48.  
  49. 1.2
  50. date     88.08.20.14.32.23;  author ouster;  state Exp;
  51. branches ;
  52. next     1.1;
  53.  
  54. 1.1
  55. date     88.08.19.18.06.06;  author ouster;  state Exp;
  56. branches ;
  57. next     ;
  58.  
  59. 1.9.1.1
  60. date     92.03.31.17.13.24;  author kupfer;  state Exp;
  61. branches ;
  62. next     ;
  63.  
  64.  
  65. desc
  66. @First version now operational.
  67. @
  68.  
  69.  
  70. 1.10
  71. log
  72. @now that gethostname() uses a system call initsprite can no longer
  73. use it to figure out the name of the host. Instead it must get the
  74. host id from the kernel, determine the host name via the Host 
  75. library, and set the host name in the kernel.
  76. @
  77. text
  78. @
  79. /*
  80.  * initsprite --
  81.  *
  82.  *    This program is the first user process execed by the Sprite kernel.
  83.  *
  84.  * Copyright 1988 Regents of the University of California
  85.  * Permission to use, copy, modify, and distribute this
  86.  * software and its documentation for any purpose and without
  87.  * fee is hereby granted, provided that the above copyright
  88.  * notice appear in all copies.  The University of California
  89.  * makes no representations about the suitability of this
  90.  * software for any purpose.  It is provided "as is" without
  91.  * express or implied warranty.
  92.  */
  93.  
  94. #ifndef lint
  95. static char rcsid[] = "$Header: /sprite/src/cmds/initsprite/RCS/initsprite.c,v 1.9 91/05/07 18:38:38 jhh Exp $ SPRITE (Berkeley)";
  96. #endif not lint
  97.  
  98. #include "option.h"
  99. #include <sprite.h>
  100. #include <errno.h>
  101. #include <fs.h>
  102. #include <fsCmd.h>
  103. #include <host.h>
  104. #include <signal.h>
  105. #include <status.h>
  106. #include <stdio.h>
  107. #include <stdlib.h>
  108. #include <string.h>
  109. #include <sysStats.h>
  110. #include <sys/file.h>
  111. #include <sys/param.h>
  112. #include <sys/wait.h>
  113.  
  114. /*
  115.  * Initial input/output device to open.
  116.  */
  117. #define CONSOLE        "/dev/console"
  118.  
  119. /*
  120.  * Command script to execute after doing bare-bones initialization.
  121.  * If a host-dependent script exists, it is used in preference to
  122.  * this one.
  123.  */
  124. #define BOOTCMDS    "/boot/bootcmds"
  125.  
  126. /*
  127.  * Program to exec if we're coming up single user.
  128.  */
  129. char    login[]    =        "login";
  130.  
  131. /*
  132.  *  Command that was used to boot the machine.
  133.  */
  134. char            *bootCommand = NULL;
  135.  
  136. /*
  137.  * TRUE => run a login after initial setup.
  138.  */
  139. Boolean            singleUser = FALSE;
  140.  
  141. /*
  142.  * TRUE => check any disks
  143.  */
  144. Boolean            checkDisk = TRUE;
  145.  
  146. int        dummy;
  147.  
  148. Option    optionArray[] = {
  149.     {OPT_STRING, "b", (Address) &bootCommand, "Boot string passed to prom."},
  150.     {OPT_TRUE, "s", (Address) &singleUser, "Boot single-user mode."},
  151.     {OPT_FALSE, "f", (Address) &checkDisk, "Don't check disks (fastboot)."},
  152.     {OPT_TRUE, "root", (Address) &dummy, "Used by kernel, but not initsprite."},
  153.     {OPT_TRUE, "nonroot", (Address) &dummy, 
  154.         "Used by kernel, but not initsprite."},
  155.     {OPT_STRING, "rootdisk", (Address) &dummy, 
  156.         "Used by kernel, but not initsprite."},
  157. };
  158. int numOptions = sizeof(optionArray) / sizeof(Option);
  159.  
  160. /*
  161.  *----------------------------------------------------------------------
  162.  *
  163.  * Exec --
  164.  *
  165.  *    Utility procedure to run a command and wait for the child
  166.  *    to exit.
  167.  *
  168.  * Results:
  169.  *    Returns 0 if all went well, -1 otherwise.
  170.  *
  171.  * Side effects:
  172.  *    Prints a message if an error occurs.
  173.  *
  174.  *----------------------------------------------------------------------
  175.  */
  176.  
  177. int
  178. Exec(name, argv)
  179.     char *name;            /* Name of file to exec. */
  180.     char **argv;        /* Null-terminated array of arguments. */
  181. {
  182.     int pid, childPid;
  183.     union wait status;
  184.  
  185.     pid = fork();
  186.     if (pid == 0) {
  187.     execvp(name, argv);
  188.     _exit(1);
  189.     }
  190.     if (pid < 0) {
  191.     fprintf(stderr,
  192.         "Initsprite couldn't fork child for \"%s\": %s\n",
  193.         name, strerror(errno));
  194.     return -1;
  195.     }
  196.     childPid = wait(&status);
  197.     if (childPid < 0) {
  198.     fprintf(stderr,
  199.         "Initsprite couldn't wait for \"%s\": %s\n",
  200.         name, strerror(errno));
  201.     return -1;
  202.     }
  203.     if (childPid != pid) {
  204.     fprintf(stderr, "Initsprite waited for child 0x%x, got child 0x%x.\n",
  205.         pid, childPid);
  206.     return -1;
  207.     }
  208.     if (WIFSTOPPED(status)) {
  209.     fprintf(stderr, "Initsprite child \"%s\" stopped instead of exiting.\n",
  210.         name);
  211.     return -1;
  212.     }
  213.     if (status.w_retcode != 0) {
  214.     return -1;
  215.     }
  216.     return 0;
  217. }
  218.  
  219. /*
  220.  *----------------------------------------------------------------------
  221.  *
  222.  * main --
  223.  *
  224.  *    Main program for first user process in Sprite.
  225.  *
  226.  * Results:
  227.  *    Never returns.
  228.  *
  229.  * Side effects:
  230.  *    Lots.  Read the code..
  231.  *
  232.  *----------------------------------------------------------------------
  233.  */
  234.  
  235. main(argc, argv)
  236.     int        argc;         /* Number of arguments */
  237.     char    **argv;        /* Arguments */
  238. {
  239.     char            *argArray[20];
  240.     static struct sigvec    action = {SIG_IGN, 0, 0};
  241.     static char            string[200];
  242.     static char            name[MAXHOSTNAMELEN];
  243.     static char            hostID[10];
  244.     int                i;
  245.     int                status;
  246.     int                argsReturned;
  247.     static char            hostMachType[50];
  248.     char            pathname[MAXPATHLEN];
  249.     Host_Entry             *hostInfo;
  250.     Fs_Prefix            prefix;
  251.     Host_Entry             *rootInfo;
  252.     int                spriteID;
  253.  
  254.  
  255.  
  256.     argsReturned = Opt_Parse(argc, argv, optionArray, numOptions, 0);
  257.  
  258.     /*
  259.      * Try to access the local boot directory. If it exists, then
  260.      * we have a local disk and we have to look for everything relative to
  261.      * the prefix. Otherwise we look relative to /.
  262.      */
  263.     /*
  264.      * Open the console which will in turn get inherited as stdin etc.
  265.      * by the shells that are forked.  After this, stdio can be used
  266.      * for I/O.  If this fails, exit with status 2 to indicate what
  267.      * happened (can't print a message, since there's no I/O yet).
  268.      */
  269.  
  270.     if ((open(CONSOLE, O_RDONLY, 0) != 0)
  271.         || (open(CONSOLE, O_WRONLY, 0) != 1)
  272.         || (open(CONSOLE, O_WRONLY, 0) != 2)) {
  273.     Test_PrintOut("Initsprite couldn't open console %s: %s\n",
  274.         CONSOLE, strerror(errno));
  275.     exit(2);
  276.     }
  277.     if (getwd(pathname) == 0) {
  278.     printf("Couldn't get working directory: %s\n", pathname);
  279.     } else {
  280.     printf("%s/%s starting up.\n", pathname, argv[0]);
  281.     }
  282.     if (argsReturned > 1) {
  283.     Opt_PrintUsage(argv[0], optionArray, Opt_Number(optionArray));
  284.     }
  285.     /*
  286.      * Set up signal actions.
  287.      */
  288.  
  289.     if (sigvec(SIGINT, &action, (struct sigvec *) NULL) != 0) {
  290.     fprintf(stderr,
  291.         "Warning: initsprite can't ignore SIGINT signals: %s\n", 
  292.         strerror(errno));
  293.     }
  294.     if (sigvec(SIGQUIT, &action, (struct sigvec *) NULL) != 0) {
  295.     fprintf(stderr,
  296.         "Warning: initsprite can't ignore SIGQUIT signals: %s\n",
  297.         strerror(errno));
  298.     }
  299.     if (sigvec(SIGHUP, &action, (struct sigvec *) NULL) != 0) {
  300.     fprintf(stderr,
  301.         "Warning: initsprite can't ignore SIGHUP signals: %s\n",
  302.         strerror(errno));
  303.     }
  304.     if (sigvec(SIGTERM, &action, (struct sigvec *) NULL) != 0) {
  305.     fprintf(stderr,
  306.         "Warning: initsprite can't ignore SIGTERM signals: %s\n",
  307.         strerror(errno));
  308.     }
  309.     /*
  310.      * Set up the environment.
  311.      */
  312.  
  313.     status = Proc_GetHostIDs((int *) NULL, &spriteID);
  314.     if (status != SUCCESS) {
  315.     fprintf(stderr, "Initsprite couldn't get host ID: %s\n",
  316.         Stat_GetMsg(status));
  317.     goto exitError;
  318.     }
  319.     hostInfo = Host_ByID(spriteID);
  320.     if (hostInfo == NULL) {
  321.     fprintf(stderr,
  322.         "Initsprite can't get information about host %d: %s\n",
  323.         spriteID, strerror(errno));
  324.     goto exitError;
  325.     }
  326.     strncpy(name, hostInfo->name, MAXHOSTNAMELEN);
  327.     strncpy(hostMachType, hostInfo->machType, 50);
  328.     sprintf(hostID, "%d", hostInfo->id);
  329.     Host_End();
  330.     setenv("HOST", name);
  331.     setenv("MACHINE", hostMachType);
  332.     sprintf(string, ".:./cmds:/sprite/cmds.%.50s:/sprite/cmds", hostMachType);
  333.     setenv("PATH", string);
  334.     setenv("HOME", "/");
  335.     setenv("USER", "root");
  336.  
  337.     status = Sys_SetHostName(name);
  338.     if (status != SUCCESS) {
  339.     /*
  340.      * Ignore the error if the system call was invalid. Assume we are
  341.      * running on an old kernel.
  342.      */
  343.     if (status != SYS_INVALID_SYSTEM_CALL) {
  344.         fprintf(stderr, "Initsprite couldn't set host name: %s\n",
  345.         Stat_GetMsg(status));
  346.     }
  347.     }
  348.     if (singleUser) {
  349.     /*
  350.      *    If we are coming up single user then go to a login.
  351.      */
  352.     fprintf(stderr,"Single user mode requires root password.\n");
  353.     argArray[0] = "login";
  354.     argArray[1] = "-d";
  355.     argArray[2] = CONSOLE;
  356.     argArray[3] = "-l";
  357.     argArray[4] = "root";
  358.     argArray[5] = "-t";
  359.     argArray[6] = 0;
  360.     status = Exec(login, argArray);
  361.     if (status != 0) {
  362.         argArray[0] = "csh";
  363.         argArray[1] = "-i";
  364.         argArray[2] = 0;
  365.         status = Exec("csh", argArray);
  366.     }
  367.     if (status != 0) {
  368.         fprintf(stderr, "Can't run a shell.\n");
  369.     }
  370.     fprintf(stderr,"Initsprite continuing.\n");
  371.     }
  372.     /*
  373.      * Find the root server.
  374.      */
  375.     status = SUCCESS;
  376.     for (i = 0; status == SUCCESS; i++) {
  377.     bzero((char *) &prefix, sizeof(Fs_Prefix));
  378.     status = Sys_Stats(SYS_FS_PREFIX_STATS, i, (Address) &prefix);
  379.     if (status == SUCCESS) {
  380.         if (!strcmp(prefix.prefix, "/")) {
  381.         rootInfo = Host_ByID(prefix.serverID);
  382.         setenv("ROOTSERVER", rootInfo->name);
  383.         break;
  384.         }
  385.     }
  386.     }
  387.     /*
  388.      * If there is a bootcmds file in
  389.      * the host-specific directory, execute it instead of the one in /.
  390.      * Remember that the /.cshrc file will also be loaded by csh when
  391.      * processing bootcmds.
  392.      */
  393.  
  394.     sprintf(string, "/hosts/%.50s/bootcmds", name);
  395.     if (access(string, R_OK) != 0) {
  396.     strcpy(string, BOOTCMDS);
  397.     }
  398.     fprintf(stderr, "Executing %s\n", string);
  399.     i = 0;
  400.     argArray[i++] = "csh";
  401.     argArray[i++] = string;
  402.     if (bootCommand != NULL) {
  403.     argArray[i++] = "-b";
  404.     argArray[i++] = bootCommand;
  405.     }
  406.     if (!checkDisk) {
  407.     argArray[i++] = "-f";
  408.     }
  409.     argArray[i++] = "-i";
  410.     argArray[i++] = hostID;
  411.     argArray[i++] = 0;
  412.     if (Exec("csh", argArray) == 0) {
  413.     exit(0);
  414.     }
  415.     /*
  416.      * The boot command script did not complete successfully.  
  417.      * Try to bail out to a shell.
  418.      */
  419.  
  420.     fprintf(stderr, "Initsprite: boot command file exited abnormally!\n");
  421.  
  422.     argArray[0] = "csh";
  423.     argArray[1] = "-i";
  424.     argArray[2] = 0;
  425.     execvp("csh", argArray);
  426.     fprintf(stderr, "Init failed when trying to bailout to csh: %s\n",
  427.         strerror(errno));
  428.     fprintf(stderr, "Init has run out of things to try:  nothing works.\n");
  429. exitError:
  430.     fprintf(stderr, "Initsprite exiting.\n");
  431.     exit(1);
  432. }
  433. @
  434.  
  435.  
  436. 1.9
  437. log
  438. @made rootdisk option take a string argument
  439. @
  440. text
  441. @d18 1
  442. a18 1
  443. static char rcsid[] = "$Header: /sprite/src/cmds/initsprite/RCS/initsprite.c,v 1.8 91/03/05 11:24:28 jhh Exp $ SPRITE (Berkeley)";
  444. a54 12
  445.  * Name of temporary prefix for root partition.
  446.  */
  447. char    prefix[] =         "/";
  448.  
  449. /*
  450.  * Name of local boot directory. If we have one we are booting
  451.  * standalone.
  452.  */
  453. char    localBootDir[] =     "/boot";
  454.  
  455.  
  456. /*
  457. d165 1
  458. a165 2
  459. #define HOST_NAME_LENGTH 255
  460.     static char            hostName[HOST_NAME_LENGTH];
  461. d175 1
  462. d203 1
  463. a203 1
  464.     printf("%s/initsprite starting up.\n", pathname);
  465. d236 4
  466. a239 3
  467.     if (gethostname(hostName, HOST_NAME_LENGTH) != 0) {
  468.     fprintf(stderr, "Initsprite couldn't get host name: %s\n",
  469.         strerror(errno));
  470. d242 1
  471. a242 3
  472.     hostName[HOST_NAME_LENGTH-1] = 0;
  473.     printf("hostName is %s.\n", hostName);
  474.     hostInfo = Host_ByName(hostName);
  475. d245 2
  476. a246 2
  477.         "Initsprite can't get information about host \"%s\": %s\n",
  478.         hostName, strerror(errno));
  479. d249 1
  480. d253 1
  481. a253 1
  482.     setenv("HOST", hostName);
  483. d260 11
  484. a298 1
  485.     printf("Searching for root prefix.\n");
  486. a304 1
  487.         printf("Setting ROOTSERVER = %s\n", rootInfo->name);
  488. d317 1
  489. a317 1
  490.     sprintf(string, "/hosts/%.50s/bootcmds", hostName);
  491. @
  492.  
  493.  
  494. 1.9.1.1
  495. log
  496. @Initial branch for Sprite server.
  497. @
  498. text
  499. @d18 1
  500. a18 1
  501. static char rcsid[] = "$Header: /sprite/src/cmds/initsprite/RCS/initsprite.c,v 1.9 91/05/07 18:38:38 jhh Exp $ SPRITE (Berkeley)";
  502. @
  503.  
  504.  
  505. 1.8
  506. log
  507. @new boot sequence
  508. @
  509. text
  510. @d18 1
  511. a18 1
  512. static char rcsid[] = "$Header: /a/newcmds/initsprite/RCS/initsprite.c,v 1.6 89/07/18 13:46:12 jhh Exp $ SPRITE (Berkeley)";
  513. d90 1
  514. a90 1
  515.     {OPT_TRUE, "rootdisk", (Address) &dummy, 
  516. @
  517.  
  518.  
  519. 1.7
  520. log
  521. @passes -t to login process
  522. @
  523. text
  524. @a39 3
  525. #ifdef spur
  526. #define CONSOLE        "/tmp/rconsole"
  527. #else
  528. a40 1
  529. #endif
  530. a49 18
  531.  * Command script to use to set things up for a local disk.
  532.  */
  533. #define DISKCMDS    "diskcmds"
  534.  
  535. /*
  536.  * Command script to execute so set things for exporting "/".
  537.  */
  538.  
  539. #define ROOTCMDS    "rootcmds"
  540.  
  541. /*
  542.  * File that contains information about a server machine. /etc/spritehosts
  543.  * may not be available so each server has its own information about itself.
  544.  */
  545.  
  546. #define SERVERINFO        "serverInfo"
  547.  
  548. /*
  549. d57 1
  550. a57 1
  551. char    prefix[] =         "/bootTmp";
  552. d63 1
  553. a63 1
  554. char    localBootDir[] =     "/bootTmp/boot";
  555. d81 1
  556. a81 9
  557. /*
  558.  * TRUE => source rootCommands
  559.  */
  560. Boolean            runRootCmds = FALSE;
  561.  
  562. /*
  563.  * TRUE => boot as a client even if we are a file server.
  564.  */
  565. Boolean            forceClient = FALSE;
  566. d87 5
  567. a91 2
  568.     {OPT_TRUE, "x", (Address) &runRootCmds, "Source rootCmds file."},
  569.     {OPT_TRUE, "c", (Address) &forceClient, "Boot fileserver like a client."},
  570. a182 2
  571.     Boolean            standalone;
  572.     Boolean            fileServer;
  573. d185 3
  574. a197 11
  575.     if (access(prefix, F_OK) == 0) {
  576.     fileServer = TRUE;
  577.     if (!forceClient && (access(localBootDir, F_OK) == 0)) {
  578.         standalone = TRUE;
  579.     } else {
  580.         standalone = FALSE;
  581.     }
  582.     } else {
  583.     standalone = FALSE;
  584.     fileServer = FALSE;
  585.     }
  586. d248 13
  587. a260 35
  588.     if (standalone) {
  589.     FILE     *fp;
  590.     int    n;
  591.     fp = fopen(SERVERINFO,"r");
  592.     if (fp == NULL) {
  593.         fprintf(stderr, "Initsprite couldn't open %s.\n", SERVERINFO);
  594.         goto exitError;
  595.     }
  596.     n = fscanf(fp, " %s %*s %*s %*s %s %s", hostID, hostMachType,
  597.         hostName);
  598.     if (n != 3) {
  599.         fprintf(stderr, "Initsprite: can't understand %s.\n", SERVERINFO);
  600.         goto exitError;
  601.     }
  602.     fclose(fp);
  603.     } else {
  604.     Host_Entry *hostInfo;
  605.     
  606.     if (gethostname(hostName, HOST_NAME_LENGTH) != 0) {
  607.         fprintf(stderr, "Initsprite couldn't get host name: %s\n",
  608.             strerror(errno));
  609.         goto exitError;
  610.     }
  611.     hostName[HOST_NAME_LENGTH-1] = 0;
  612.     printf("hostName is %s.\n", hostName);
  613.     hostInfo = Host_ByName(hostName);
  614.     if (hostInfo == NULL) {
  615.         fprintf(stderr,
  616.             "Initsprite can't get information about host \"%s\": %s\n",
  617.             hostName, strerror(errno));
  618.         goto exitError;
  619.     }
  620.     strncpy(hostMachType, hostInfo->machType, 50);
  621.     sprintf(hostID, "%d", hostInfo->id);
  622.     Host_End();
  623. d262 3
  624. a285 4
  625.         if (!standalone) {
  626.         fprintf(stderr, "Can't exec login. Bailing to shell.\n");
  627.         fflush(stderr);
  628.         }
  629. d297 1
  630. a297 8
  631.      * After the console has been opened, the stdio routines can be used.
  632.      * Execute command scripts to do system initialization.
  633.      *
  634.      * rootcmds is run when a non-root file server is supposed to export
  635.      * root. This allows it to do special initialization.
  636.      *
  637.      * diskcmds is used for machines with local disks to configure
  638.      * the filesystems they control.
  639. d299 12
  640. a310 31
  641.  
  642.     if (!fileServer) {
  643.     /*
  644.      * No local storage.
  645.      */
  646.     fprintf(stderr, "No local disk.\n");
  647.     } else {
  648.     printf("Executing %s.\n", DISKCMDS);
  649.     i = 0;
  650.     argArray[i++] = "csh";
  651.     argArray[i++] = "-f";
  652.     argArray[i++] = DISKCMDS;
  653.     if (bootCommand != NULL) {
  654.         argArray[i++] = "-b";
  655.         argArray[i++] = bootCommand;
  656.     }
  657.     if (!checkDisk) {
  658.         argArray[i++] = "-f";
  659.     }
  660.     argArray[i++] = "-i";
  661.     argArray[i++] = hostID;
  662.     argArray[i++] = 0;
  663.     (void) Exec("csh", argArray);
  664.  
  665.     if (runRootCmds) {
  666.         printf("Executing %s.\n", ROOTCMDS);
  667.         i = 0;
  668.         argArray[i++] = "csh";
  669.         argArray[i++] = "-f";
  670.         argArray[i++] = ROOTCMDS;
  671.         (void) Exec("csh", argArray);
  672. a312 1
  673.  
  674. d314 1
  675. a314 2
  676.      * After initializing the local disk, the network wide initialization
  677.      * file, /bootcmds, is executed.  If there is a bootcmds file in
  678. a317 4
  679.      *
  680.      * If we are booting standalone then now is the time to look for
  681.      * the real root server.  Check the prefix table to make sure we
  682.      * aren't exporting "/", then delete "/" and look for the server.
  683. d319 1
  684. a319 34
  685.  
  686.     if (standalone) {
  687.     static     char    rootPrefix[] = "/";
  688.     Fs_Prefix    prefix;
  689.     Boolean        deleteRoot;
  690.  
  691.     deleteRoot = TRUE;
  692.     status = SUCCESS;
  693.  
  694.     for (i = 0; status == SUCCESS; i++) {
  695.         bzero((char *) &prefix, sizeof(Fs_Prefix));
  696.         status = Sys_Stats(SYS_FS_PREFIX_STATS, i, (Address) &prefix);
  697.         if (status == SUCCESS) {
  698.         if (!strcmp(prefix.prefix, "/")) {
  699.             if (prefix.flags & FS_EXPORTED_PREFIX) {
  700.             deleteRoot = FALSE;
  701.             }
  702.             break;
  703.         }
  704.         }
  705.     }
  706.     if (deleteRoot) {
  707.         Fs_Command(FS_PREFIX_CLEAR, strlen(rootPrefix) + 1, rootPrefix);
  708.         do {
  709.         status = access("/", R_OK | X_OK);
  710.         if (status) {
  711.             perror("Can't access \"/\": ");
  712.             fprintf(stderr, "Will try again after 1 minute.\n");
  713.             fflush(stderr);
  714.             sleep(60);
  715.         }
  716.         } while (status);
  717.     }
  718.     }
  719. d325 13
  720. a337 3
  721.     argArray[0] = "csh";
  722.     argArray[1] = string;
  723.     argArray[2] = 0;
  724. a338 7
  725.     if (fileServer) {
  726.         status = Fs_Command(FS_PREFIX_DELETE, strlen(prefix) + 1, prefix);
  727.         if (status != SUCCESS) {
  728.         fprintf(stderr, "Couldn't unmount %s: %s\n", prefix,
  729.             Stat_GetMsg(status));
  730.         }
  731.     }
  732. @
  733.  
  734.  
  735. 1.6
  736. log
  737. @changed ifdef SPUR to ifdef spur
  738. @
  739. text
  740. @d18 1
  741. a18 1
  742. static char rcsid[] = "$Header: /a/newcmds/initsprite/RCS/initsprite.c,v 1.5 89/07/12 11:47:26 jhh Exp $ SPRITE (Berkeley)";
  743. d338 2
  744. a339 1
  745.     argArray[5] = 0;
  746. @
  747.  
  748.  
  749. 1.5
  750. log
  751. @fileservers can now deal with a trashed local root 
  752. @
  753. text
  754. @d18 1
  755. a18 1
  756. static char rcsid[] = "$Header: /a/newcmds/initsprite/RCS/initsprite.c,v 1.4 89/06/19 14:33:58 jhh Exp $ SPRITE (Berkeley)";
  757. d40 1
  758. a40 1
  759. #ifdef SPUR
  760. @
  761.  
  762.  
  763. 1.4
  764. log
  765. @New boot sequence
  766. @
  767. text
  768. @d18 1
  769. a18 1
  770. static char rcsid[] = "$Header: /a/newcmds/initsprite/RCS/initsprite.c,v 1.3 89/01/11 12:21:21 mendel Exp Locker: jhh $ SPRITE (Berkeley)";
  771. d81 6
  772. d220 1
  773. a220 1
  774.      * Try to access the root partition temporary prefix. If it exists, then
  775. d226 1
  776. a226 1
  777.     if (!forceClient) {
  778. @
  779.  
  780.  
  781. 1.3
  782. log
  783. @Open /tmp/rconsole rather that /tmp/console if spur.
  784. @
  785. text
  786. @d1 1
  787. d18 1
  788. a18 1
  789. static char rcsid[] = "$Header: initsprite.c,v 1.2 88/08/20 14:32:23 ouster Exp $ SPRITE (Berkeley)";
  790. d21 2
  791. d24 2
  792. d28 1
  793. d32 1
  794. d34 1
  795. a37 5
  796.  * Shell started up for users, regardless of what is in /etc/passwd.
  797.  */
  798. char localShell[] = "/local/bootBin/csh";
  799.  
  800. /*
  801. d51 1
  802. a51 1
  803. #define BOOTCMDS    "/bootcmds"
  804. d56 59
  805. a114 1
  806. #define DISKCMDS    "/local/diskcmds"
  807. a143 3
  808.     execvp(localShell, argv);
  809.     fprintf(stderr, "Initsprite couldn't exec \"%s\": %s\n", 
  810.         name, strerror(errno));
  811. d191 3
  812. a193 1
  813. main()
  814. d195 1
  815. a195 1
  816.     char            *argArray[10];
  817. a196 1
  818.     Host_Entry            *hostInfo;
  819. d200 29
  820. a228 1
  821.  
  822. d239 2
  823. a240 2
  824.     Test_PrintOut("Initsprite couldn't open console: %s\n",
  825.         strerror(errno));
  826. d243 8
  827. a250 2
  828.     fprintf(stderr, "Initsprite starting up.\n");
  829.  
  830. a274 1
  831.  
  832. d279 35
  833. a313 12
  834.     if (gethostname(hostName, HOST_NAME_LENGTH) != 0) {
  835.     fprintf(stderr, "Initsprite couldn't get host name: %s\n",
  836.         strerror(errno));
  837.     exit(1);
  838.     }
  839.     hostName[HOST_NAME_LENGTH-1] = 0;
  840.     hostInfo = Host_ByName(hostName);
  841.     if (hostInfo == NULL) {
  842.     fprintf(stderr,
  843.         "Initsprite can't get information about host \"%s\": %s\n",
  844.         hostName, strerror(errno));
  845.     exit(1);
  846. d315 3
  847. a317 4
  848.     setenv("HOST", hostInfo->name);
  849.     setenv("MACHINE", hostInfo->machType);
  850.     sprintf(string, ".:/sprite/cmds.%.50s:/sprite/cmds",
  851.         hostInfo->machType);
  852. a320 1
  853.     Host_End();
  854. d322 27
  855. d353 4
  856. a356 1
  857.      * /local/diskcmds is used for machines with local disks to configure
  858. a357 1
  859.      * Echo is turned on, "-x", so the attachDisk commands are visible.
  860. d360 1
  861. a360 1
  862.     if (access(localShell, X_OK) != 0) {
  863. d366 25
  864. a390 5
  865.     argArray[0] = "csh";
  866.     argArray[1] = "-fx";
  867.     argArray[2] = DISKCMDS;
  868.     argArray[3] = 0;
  869.     (void) Exec(localShell, argArray);
  870. d399 4
  871. d405 34
  872. a438 1
  873.     sprintf(string, "/hosts/%.50s/bootcmds", hostInfo->name);
  874. d447 7
  875. a455 1
  876.  
  877. d464 2
  878. a465 1
  879.     argArray[1] = 0;
  880. a468 4
  881.     argArray[0] = localShell;
  882.     execvp(localShell, argArray);
  883.     fprintf(stderr, "Init failed when trying to bailout to %s: %s\n",
  884.         localShell, strerror(errno));
  885. d470 2
  886. @
  887.  
  888.  
  889. 1.2
  890. log
  891. @Lint cleanup.
  892. @
  893. text
  894. @d17 1
  895. a17 1
  896. static char rcsid[] = "$Header: initsprite.c,v 1.1 88/08/19 18:06:06 ouster Exp $ SPRITE (Berkeley)";
  897. d37 3
  898. d41 1
  899. @
  900.  
  901.  
  902. 1.1
  903. log
  904. @Initial revision
  905. @
  906. text
  907. @d17 1
  908. a17 1
  909. static char rcsid[] = "$Header: initSprite.c,v 1.16 88/06/10 10:17:56 ouster Exp $ SPRITE (Berkeley)";
  910. d24 1
  911. d69 1
  912. a69 1
  913. Exec(name, argv, usePath)
  914. d98 1
  915. a98 1
  916.     fprintf("Initsprite waited for child 0x%x, got child 0x%x.\n",
  917. d131 4
  918. a134 5
  919.     char        *argArray[10];
  920.     struct sigvec    action = {SIG_IGN, 0, 0};
  921.     Host_Entry        *hostInfo;
  922.     int            hostId;
  923.     static char        string[200];
  924. d136 1
  925. a136 1
  926.     static char        hostName[HOST_NAME_LENGTH];
  927. @
  928.